package salary

type Affiliation interface {
	calculateDeductions(paycheck Paycheck) float64
}

type UnionAffiliation struct {
	MemberId       int             // 会员id
	Dues           float64         // 应缴
	ServiceCharges []ServiceCharge // 服务费
}

func (u UnionAffiliation) calculateDeductions(paycheck Paycheck) float64 {
	charges := u.ServiceCharges
	sum := u.Dues
	for _, charge := range charges {
		if IsBetween(charge.Date, paycheck.PayStartTime, paycheck.PayDate) {
			sum += charge.Amount
		}
	}
	return sum
}

type NoAffiliation struct {
}

func (n NoAffiliation) calculateDeductions(paycheck Paycheck) float64 {
	return 0
}
